﻿using B.S.BasicData.Api.Read.Application.Command.Menu;
using B.S.BasicData.Domian.Entities.RBAC;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Infrastructure.Interface;
using MediatR;

namespace B.S.BasicData.Api.Read.Application.Handler.Menu
{
    public class ShowRoleMenuHandler : IRequestHandler<ShowRoleMenuCommand, ApiResult<List<RoleModel>>>
    {
        private readonly IBaseRepository<RoleModel> roleRepo;

        public ShowRoleMenuHandler(IBaseRepository<RoleModel>roleRepo)
        {
            this.roleRepo = roleRepo;
        }
        public Task<ApiResult<List<RoleModel>>> Handle(ShowRoleMenuCommand request, CancellationToken cancellationToken)
        {
            var res=new ApiResult<List<RoleModel>>();
            var role = roleRepo.GetAll();
            res.Message = "显示成功";
            res.Code=ApiEnum.Ok;
            res.Data=role.ToList();
            return Task.FromResult(res);
        }
    }
}
